<style>
.layui-table-cell {
  height: auto;
  line-height: auto;
  fixed:right
}
</style>
<span class="layui-breadcrumb"  lay-separator="/">
  <a href="/">商家后台</a>
  <a><cite>订单列表</cite></a>
</span>
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
    <ul class="layui-tab-title">
        <a href="/order/lists"><li <?php if($pay_status == '' && $fahuo_status == ''):?>class="layui-this"<?php endif;?>>全部订单</li></a>
        <a href="/order/lists?pay_status=0"><li <?php if($pay_status != '' && $pay_status == 0):?>class="layui-this"<?php endif;?>>未支付</li></a>
        <a href="/order/lists?fahuo_status=0&pay_status=1"><li <?php if($fahuo_status == 0 && $pay_status == 1):?>class="layui-this"<?php endif;?> class="">未发货</li></a>
        <a href="/order/lists?fahuo_status=1&pay_status=1"><li <?php if($fahuo_status == 1):?>class="layui-this"<?php endif;?> class="">已发货</li></a>
    </ul>
</div
<div class="layui-card">
    <div class="layui-card-body">
        <div class="layui-row layui-form" id="form">
            <div class="layui-col-lg6">
                <div class="layui-col-lg4">
                    <input type="text" id="min_time" name="min_time" placeholder="最小时间" class="layui-input">
                </div>
                <div class="layui-col-lg4">
                        <input type="text" id="max_time" name="max_time" placeholder="最大时间" class="layui-input">
                </div>
                <div class="layui-col-lg4">
                    <select lay-filter="com_quicktime">
                        <option value="0">快捷时间</option>
                        <option value="1">最近1天</option>
                        <option value="2">最近2天</option>
                        <option value="3">最近3天</option>
                        <option value="4">最近4天</option>
                        <option value="5">最近5天</option>
                        <option value="6">最近6天</option>
                        <option value="7">最近7天</option>
                        <option value="8">最近8天</option>
                        <option value="9">最近9天</option>
                        <option value="10">最近10天</option>
                        <option value="20">最近20天</option>
                        <option value="30">最近30天</option>
                        <option value="60">最近60天</option>
                        <option value="90">最近90天</option>
                        <option value="365">最近365天</option>
                    </select>
                </div>
            </div>
            <div class="layui-col-lg2">
                <input type="text" name="keyword" placeholder="请输入关键词" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-col-lg4">
                <button class="layui-btn layui-btn-normal" onclick="search()">搜索</button>
                <button class="layui-btn newPage" url="<?=url('order/downOrder') ?>" width="80%" heigth="80%">下载</button>
                <button class="layui-btn layui-btn-primary" onclick="search(1)">全部下载</button>
            </div>
        </div>
        <div class="layui-row">
            <table class="layui-hide" lay-filter="table" id="table"></table>
        </div>
    </div>
</div>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="detail">详情</a>
</script>
<script>
layui.use(['table', 'form'], function() {
    var form = layui.form;
    var table = layui.table;
    var $ = layui.$;
    form.render('select');
    search = function(is_down=0) {
        var url = "/order/lists?pay_status=<?=$pay_status;?>&fahuo_status=<?=$fahuo_status;?>";
        var data = $("#form").find("[name]");
        var where = {is_down:is_down};
        data.each(function(i, e) {
            where[$(e).attr('name')] = $(e).val();
        });
        table.render({
            elem: '#table',
            url: url,
            where: where,
            method: 'post',
            cellMinWidth: 180,
            page: true,
            cols: [
                [
                    { type: 'checkbox' },
                    { field: 'order_no', title: '订单编号', width: 180, sort: true},
                    { field: 'goods_title', title: '商品' },
                    { field: 'sum_price',width: 100, title: '订单总价' },
                    { field: 'pay_status', width: 80, title: '支付状态' },
                    { field: 'fahuo_status', width: 80, title: '发货状态' },
                    { field: 'create_time', title: '时间' },
                    { field: 'action', title: '操作', width: 150, align: 'center', toolbar: '#barDemo'}
                ]
            ],
            done:function(res, curr, count){
                _action(res);
            }
        });
    };
    search();
    //监听工具条
    table.on('tool(table)', function(obj) {
        var data = obj.data;
        if (obj.event === 'detail') {
            window.location.href = '/order/detail?order_no=' + data.order_no;
            // layer.open({
            //     title: '查看',
            //     type: 2,
            //     area: ['80%', '80%'],
            //     content: '/order/detail?order_no=' + data.order_no
            // });
        }
    });
});
</script>
</script>
